home *** CD-ROM | disk | FTP | other *** search
- using System;
- using System.Collections;
- using System.IO;
- using System.Web;
- using System.Web.Caching;
- using System.Web.UI;
- using GBPVR.Public;
- using GBPVRSchedule;
- using gbweb.classes;
-
- namespace gbweb
- {
- /// <summary>
- /// Summary description for Credits.
- /// </summary>
- public partial class Credits2 : Page
- {
-
- protected string programUniqueIdentifier;
- private const string hdrActors = "<div class=\"headerRow\">Actors</div>\n";
- private const string hdrDirectors = "<div class=\"headerRow\">Directors</div>\n";
- private const string hdrExecProd = "<div class=\"headerRow\">Executive Producers</div>\n";
- private const string hdrProducers = "<div class=\"headerRow\">Producers</div>\n";
- private const string hdrWriters = "<div class=\"headerRow\">Writers</div>\n";
- private const string hdrGuestStars = "<div class=\"headerRow\">Guest Stars</div>\n";
- private const string hdrHosts = "<div class=\"headerRow\">Hosts</div>\n";
- private const string hdrNarrators = "<div class=\"headerRow\">Narrators</div>\n";
- private const string hdrJudges = "<div class=\"headerRow\">Judges</div>\n";
- private const string hdrContestants = "<div class=\"headerRow\">Contestants</div>\n";
- private const string hdrGuests = "<div class=\"headerRow\">Guests</div>\n";
-
-
- protected void Page_Load(object sender, EventArgs e)
- {
- getTheme();
-
- if (!IsPostBack)
- {
- Schedule scheduleHelper = Global.Schedule;
-
- Programme programme = scheduleHelper.GetProgrammeByOID(int.Parse(Request.Params["id"]));
- // show programme details
- showTitle.Text = programme.getTitle();
- programUniqueIdentifier = programme.getUniqueProgrammeIdentifier();
- showSubTitle.Text = programme.getSubTitle();
- if (showSubTitle.Text.Length <1 )
- {
- EPISODE_SUBTITLE.Visible = false;
- }
- else
- {
- EPISODE_SUBTITLE.Visible = true;
- }
-
- bool ExtendedEWAEnabled = ExtendedEWA.Initialize();
-
- string description = DetailDisplay2.getDetailDisplay(programme);
-
- if (ExtendedEWAEnabled)
- {
- //Open the ExtendedEWA DB
- ExtendedEWA.OpenExtendedEWADB();
-
- //Pull all the cast/crew found for the show
- ArrayList cast = ExtendedEWA.GetCast(programme.getUniqueProgrammeIdentifier());
-
- //Close the ExtendedEWA DB
- ExtendedEWA.CloseExtendedEWADB();
-
- //If any cast was found load up the information
- if (cast.Count > 0)
- {
- //Create the table arrays to hold any found crew
- ArrayList actors = new ArrayList();
- ArrayList directors = new ArrayList();
- ArrayList producers = new ArrayList();
- ArrayList writers = new ArrayList();
- ArrayList execProducers = new ArrayList();
- ArrayList guestStars = new ArrayList();
- ArrayList hosts = new ArrayList();
- ArrayList narrators = new ArrayList();
- ArrayList judges = new ArrayList();
- ArrayList contestants = new ArrayList();
- ArrayList guests = new ArrayList();
-
- foreach (ExtendedEWA.Crew crew in cast)
- {
- switch (crew.Role)
- {
- case ExtendedEWA.Role.Actor:
- actors.Add(crew);
- break;
- case ExtendedEWA.Role.Director:
- directors.Add(crew);
- break;
- case ExtendedEWA.Role.Producer:
- producers.Add(crew);
- break;
- case ExtendedEWA.Role.Writer:
- writers.Add(crew);
- break;
- case ExtendedEWA.Role.ExecProducer:
- execProducers.Add(crew);
- break;
- case ExtendedEWA.Role.GuestStar:
- guestStars.Add(crew);
- break;
- case ExtendedEWA.Role.Host:
- hosts.Add(crew);
- break;
- case ExtendedEWA.Role.Narrator:
- narrators.Add(crew);
- break;
- case ExtendedEWA.Role.Judge:
- judges.Add(crew);
- break;
- case ExtendedEWA.Role.Contestant:
- contestants.Add(crew);
- break;
- case ExtendedEWA.Role.Guest:
- guests.Add(crew);
- break;
- }
- }
-
- //Load the data
- ArrayList foundCrew = new ArrayList();
-
- if (actors.Count > 0)
- {
- foundCrew.Add(1);
- }
- else
- {
- ACTORS.Visible = false;
- }
- if (directors.Count > 0)
- {
- foundCrew.Add(2);
- }
- else
- {
- DIRECTORS.Visible = false;
- }
- if (producers.Count > 0)
- {
- foundCrew.Add(3);
- }
- else
- {
- PRODUCERS.Visible = false;
- }
- if (writers.Count > 0)
- {
- foundCrew.Add(4);
- }
- else
- {
- WRITERS.Visible = false;
- }
- if (execProducers.Count > 0)
- {
- foundCrew.Add(5);
- }
- else
- {
- EXEC_PRODUCERS.Visible = false;
- }
- if (guestStars.Count > 0)
- {
- foundCrew.Add(6);
- }
- else
- {
- GUEST_STARS.Visible = false;
- }
- if (narrators.Count > 0)
- {
- foundCrew.Add(7);
- }
- else
- {
- NARRATORS.Visible = false;
- }
- if (judges.Count > 0)
- {
- foundCrew.Add(8);
- }
- else
- {
- JUDGES.Visible = false;
- }
- if (hosts.Count > 0)
- {
- foundCrew.Add(9);
- }
- else
- {
- HOSTS.Visible = false;
- }
- if (contestants.Count > 0)
- {
- foundCrew.Add(10);
- }
- else
- {
- CONTESTANTS.Visible = false;
- }
- if (guests.Count > 0)
- {
- foundCrew.Add(11);
- }
- else
- {
- GUESTS.Visible = false;
- }
-
- string styleWidth1 = string.Empty;
- string styleWidth2 = string.Empty;
- switch (foundCrew.Count)
- {
- case 0:
- break;
- case 1:
- styleWidth1 = "99%";
- styleWidth2 = "99%";
- break;
- case 2:
- styleWidth1 = "49%";
- styleWidth2 = "50%";
- break;
- case 3:
- styleWidth1 = "33%";
- styleWidth2 = "33%";
- break;
- case 4:
- styleWidth1 = "24%";
- styleWidth2 = "27%";
- break;
- case 5:
- styleWidth1 = "19%";
- styleWidth2 = "23%";
- break;
- case 6:
- styleWidth1 = "16%";
- styleWidth2 = "19%";
- break;
- case 7:
- styleWidth1 = "14%";
- styleWidth2 = "15%";
- break;
- case 8:
- styleWidth1 = "12%";
- styleWidth2 = "15";
- break;
- case 9:
- styleWidth1 = "11%";
- styleWidth2 = "11%";
- break;
- case 10:
- styleWidth1 = "10%";
- styleWidth2 = "9%";
- break;
- case 11:
- styleWidth1 = "9%";
- styleWidth2 = "9%";
- break;
- }
- string styleWidth = styleWidth1;
- string border = "\"none\"";
- for (int a = 0; a < foundCrew.Count; a++)
- {
- if (a == (foundCrew.Count - 1))
- {
- styleWidth = styleWidth2;
- border = "\"1px solid #000000\"";
- }
-
- switch ((int) foundCrew[a])
- {
- case 1:
- ACTORS.Style.Add("width", styleWidth);
- ACTORS.Style.Add("border-right", border);
- ACTORS.InnerHtml = fillDiv(actors, hdrActors);
- break;
- case 2:
- DIRECTORS.Style.Add("width", styleWidth);
- DIRECTORS.Style.Add("border-right", border);
- DIRECTORS.InnerHtml = fillDiv(directors, hdrDirectors);
- break;
- case 3:
- PRODUCERS.Style.Add("width", styleWidth);
- PRODUCERS.Style.Add("border-right", border);
- PRODUCERS.InnerHtml = fillDiv(producers, hdrProducers);
- break;
- case 4:
- WRITERS.Style.Add("width", styleWidth);
- WRITERS.Style.Add("border-right", border);
- WRITERS.InnerHtml = fillDiv(writers, hdrWriters);
- break;
- case 5:
- EXEC_PRODUCERS.Style.Add("width", styleWidth);
- EXEC_PRODUCERS.Style.Add("border-right", border);
- EXEC_PRODUCERS.InnerHtml = fillDiv(execProducers, hdrExecProd);
- break;
- case 6:
- GUEST_STARS.Style.Add("width", styleWidth);
- GUEST_STARS.Style.Add("border-right", border);
- GUEST_STARS.InnerHtml = fillDiv(guestStars, hdrGuestStars);
- break;
- case 7:
- NARRATORS.Style.Add("width", styleWidth);
- NARRATORS.Style.Add("border-right", border);
- NARRATORS.InnerHtml = fillDiv(narrators, hdrNarrators);
- break;
- case 8:
- JUDGES.Style.Add("width", styleWidth);
- JUDGES.Style.Add("border-right", border);
- JUDGES.InnerHtml = fillDiv(judges, hdrJudges);
- break;
- case 9:
- HOSTS.Style.Add("width", styleWidth);
- HOSTS.Style.Add("border-right", border);
- HOSTS.InnerHtml = fillDiv(hosts, hdrHosts);
- break;
- case 10:
- CONTESTANTS.Style.Add("width", styleWidth);
- CONTESTANTS.Style.Add("border-right", border);
- CONTESTANTS.InnerHtml = fillDiv(contestants, hdrContestants);
- break;
- case 11:
- GUESTS.Style.Add("width", styleWidth);
- GUESTS.Style.Add("border-right", border);
- GUESTS.InnerHtml = fillDiv(guests, hdrGuests);
- break;
- }
- }
- }
- else
- {
- CREDITS.InnerHtml = "<span class=\"infoTitle\">No Credit Information Available For This Programme.</span>";
- }
- }
-
-
- //Load the show description/date/channel
- desc.InnerHtml = description;
-
- showStartDate.Text = programme.getStartTime().ToLongDateString();
- //showTimes.Text = programme.getStartTime().ToShortTimeString() + " - " + programme.getEndTime().ToShortTimeString();
-
- Channel channel = scheduleHelper.GetChannelByOID(programme.getChannelOID());
-
- if (channel != null)
- {
- string channelName = channel.getName();
- if (channelName.StartsWith(channel.getChannelNumber().ToString()))
- // cosmetic stuff for my american friends
- {
- channelName = channelName.Substring(channel.getChannelNumber().ToString().Length);
- }
- showChannelNumber.Text = channel.getChannelNumber().ToString();
- showChannelName.Text = channelName;
- string channelIcon = GetChannelIcon(channel.getChannelNumber(), new string[] { channel.getName(), channelName });
- if (channelIcon != null)
- {
- CHANNEL_ICON.InnerHtml = "<img src=\"" + Download.GetDownloadUrl(false, true, Download.InternalFiles.ChannelIcon, Server.UrlEncode(channelIcon)) + "\" alt=\"\" width=\"67\" height=\"50\" hspace=\"0\" vspace=\"0\" border=\"1\" runat=\"server\">";
- }
- else
- {
- CHANNEL_ICON.Visible = false;
- }
- }
- else
- {
- CHANNEL_ICON.Visible = false;
- }
- }
- }
-
- private static string fillDiv(ArrayList crewlist, string hdr)
- {
- string div = hdr;
- div += "<div class=\"listings\">";
- string innerInfo = string.Empty;
- while (crewlist.Count > 0)
- {
- ExtendedEWA.Crew crew = (ExtendedEWA.Crew)crewlist[0];
- crewlist.Remove(crew);
-
- innerInfo += "<a href=\"http://www.imdb.com/find?s=all&q=" + crew.GivenName + "+" + crew.SurName + "\" onclick=\"EditPop2(this,'IMDB');return false;\" class=\"cellItem\">" + crew.GivenName + " " + crew.SurName + "</a><br>\n";
- }
- div += innerInfo + "</div>\n";
- return div;
- }
-
- private void getTheme()
- {
- string theme = Convert.ToString(Session["theme"]);
-
- if (theme != null && theme != "")
- {
- return;
- }
- else
- {
- HttpCookie cookie = Request.Cookies["theme"];
- if (cookie != null && cookie.Value.Length > 0)
- {
- theme = cookie.Value;
- }
- else
- {
- theme = "Default";
- }
- Session["theme"] = "themes/" + theme;
- return;
- }
- }
-
- private static string channelIconPath;
- private static string[] channelIconExtensions;
-
- public string GetChannelIcon(int channelNumber, string[] channelNames)
- {
- // Get the Channel Icon Directory
- if (channelIconPath == null)
- {
- lock (typeof(Credits2))
- {
- if (channelIconPath == null)
- {
- channelIconPath = Path.Combine(Global.Settings.GetInstallDir(), @"media\ChannelLogos");
- channelIconExtensions = Global.Settings.channelIconExtensions.Split(',');
- }
- }
- }
-
- Hashtable channelIconCache = (Hashtable)Cache["channelIconCache"];
- if (channelIconCache == null)
- {
- lock (typeof(Credits2))
- {
- channelIconCache = (Hashtable)Cache["channelIconCache"];
- if (channelIconCache == null)
- {
- channelIconCache = new Hashtable();
- Cache.Add(
- "channelIconCache",
- channelIconCache,
- new CacheDependency(channelIconPath),
- DateTime.MaxValue,
- //DateTime.Now.AddMinutes(30),
- //TimeSpan.Zero,
- Cache.NoSlidingExpiration,
- CacheItemPriority.Normal,
- null);
- }
- }
- }
-
- if (channelIconCache.ContainsKey(channelNumber))
- {
- return (string)channelIconCache[channelNumber];
- }
-
- lock (channelIconCache)
- {
- if (channelIconCache.ContainsKey(channelNumber))
- {
- return (string)channelIconCache[channelNumber];
- }
-
- string channelIconFile = null;
- foreach (string channelName in channelNames)
- {
- foreach (string channelIconExtension in channelIconExtensions)
- {
- string cleanName = channelName;
- string channelNameWork = channelName;
- while (cleanName.Contains("/"))
- {
- if (channelNameWork.Contains("/"))
- {
- cleanName = channelNameWork.Remove(channelNameWork.IndexOf("/"), 1);
- channelNameWork = cleanName;
- }
- }
- string probeFile = cleanName + "." + channelIconExtension;
- if (File.Exists(Path.Combine(channelIconPath, probeFile)))
- {
- channelIconFile = probeFile;
- break;
- }
- }
- if (channelIconFile != null) break;
- }
- channelIconCache[channelNumber] = channelIconFile;
- return channelIconFile;
- }
- }
-
- #region Web Form Designer generated code
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN: This call is required by the ASP.NET Web Form Designer.
- //
- InitializeComponent();
- base.OnInit(e);
- }
-
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
-
- }
- #endregion
- }
- }
-